import { HttpException } from "@nestjs/common";

import ErrorEnum from "../constant/error-enum";

class BusinessException extends HttpException {
    constructor(exceptionKey?: keyof typeof ErrorEnum, msg?: string) {
        const exception = exceptionKey ? ErrorEnum[exceptionKey] : ErrorEnum.SYSTEM_ERROR;
        super(msg || exception.msg, exception.code);
    }
}

export default BusinessException;
